<?php

use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\widgets\LinkPager;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel app\models\search\AsrPlanSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '';
$this->params['breadcrumbs'][] = $this->title;

?>
<a id="back" class="btn btn-default pull-left" href="/asr-plan/index" ><i class="fa fa-backward"></i> 返回</a>
<br>
<br>
<div class="nav-tabs-custom">
    <ul class="nav nav-tabs">
        <li class="active"><a href="view?id=<?= $id?>" data-toggle="tab"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">全部客户</font></font></a></li>
        <li><a href="potnetial?id=<?= $id?>" ><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">潜力客户</font></font></a></li>
        <li><a href="common?id=<?= $id?>"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">普通客户</font></font></a></li>
        <li><a href="deny?id=<?=$id?>"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">拒绝客户</font></font></a></li>
        <li><a href="not?id=<?=$id?>"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">未接通客户</font></font></a></li>
    </ul>
        <br>
    <a class="btn btn-success" title="下载excel号码表" href="downloadview?id=<?=$id?>">下载号码</a>
    <div class="tab-content">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>号码</th>
                    <th>姓名</th>
                    <th>公司</th>
                    <th>拨打时间</th>
                    <th>通话时长</th>
                    <th>拨打次数</th>
                    <th>客户类型</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($model as $key => $value) : ?>
                    <tr>
                        <td><?php echo $value['phone_num'];?></td>
                        <td><?php echo $value['username'];?></td>
                        <td><?php echo $value['company_name'];?></td>
                        <td>
                            <?php if($value['updated_at']) {
                                echo date('Y-m-d H:i:s',$value['updated_at']);
                                exit;
                            } else{
                                if($value['created_at']) {
                                    echo date('Y-m-d H:i:s', $value['created_at']);
                                }else{
                                    echo '未拨打';
                                }
                            }
                            ?>
                        </td>
                        <td><?php echo $value['call_time'];?></td>
                        <td><?php echo $value['call_number'];?></td>
                        <td>
                            <?php if($value['call_time']<=25){
                                echo '拒绝客户';
                            }elseif($value['call_time']<=45){
                                echo '普通客户';
                            }else{
                                echo '潜力用户';
                            }
                            ?>
                        </td>
                        <td>
                            <button class="btn  btn-primary fa fa-detail" data-toggle="modal" data-target="#myModal">
                                详情
                            </button>
                            <!-- 模态框（Modal） -->
                            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                                &times;
                                            </button>
                                            <h4 class="modal-title" id="myModalLabel">
                                                对话过程
                                            </h4>
                                        </div>
                                        <div class="modal-body">
                                            在这里添加一些文本
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                                            </button>
                                            <button type="button" class="btn btn-primary" data-dismiss="modal">
                                                确定
                                            </button>
<!--                                            <script> $('#mymodel').on('hide.bs.mo', function () {-->
<!--                                                    alert('模态框关闭了');-->
<!--                                                });</script>-->
                                        </div>
                                    </div><!-- /.modal-content -->
                                </div><!-- /.modal -->
                            </div>
                        </td>
                    </tr>
                <?php endforeach;?>
                <tr>
                    <td><input id="num" class="btn btn-default btn-xs btn-delete" placeholder="每页显示的条数" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"></td>
                </tr>

                </tbody>

            </table>
            <?php
            echo LinkPager::widget([
                'pagination' => $pages,
            ]);
            ?>
        <!-- /.tab-pane -->
    </div>


</div>

<script type="text/javascript">
    $(function () {
        var Default = {
            animationSpeed: 500,
        }

        $('#num').focusout(function () {//当鼠标失去焦点是触发事件,实现用户自定义分页
            var url = "<?= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ?>";
            $.ajax({
                type: 'post',
                async: true,
                url: url,
                data: {pageSize: $("#num").val()},
                success: function (data) {
                    window.location.reload();
                },
                error: function (error) {

                }
            });
        });
    });
</script>
